<!DOCTYPE html>
<html>
  <head>
    <title>反馈类型设置</title>
    <include file='public/head'>
    <style>
        .layui-legend-size{font-size:14px !important;}
        .layui-nopadding{padding:0 !important;}
        .layui-overflow{overflow:auto;}
        .layui-nomargin{margin: 0 !important;}
        .layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}
        .layui-input{height:30px !important; }
        .layui-form-search-item .layui-inline{margin-bottom: 5px;} 
        .layui-form-search-item label{margin-left: 15px;}
        .layui-table-page {padding: 7px 0px 0px;}
        .layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
    </style>
</head>
<body>
  <!-- layui-tab开始 -->
  <div class="layui-tab" lay-fliter="demo-tab">

    <br>
      
    <!-- 内容开始 -->
    <div class="layui-card">
        
    <!-- 表头按钮开始 -->
    <div class="layui-card-header layui-bg-gray layui-bottom">
        <a href="javascript:;" class="layui-btn layui-btn-xs  add-btn" >
            <i class="layui-icon">&#xe624;</i>添加类型
        </a>
    </div>    
    <!-- 表头按钮结束 -->

    <!-- 数据表格开始 -->
    <form method="post" id="f">
    <table class="layui-table layui-nomargin">
        <thead>
            <tr>
                <th>ID</th>
                <th>类型标题</th>
                <th>操作</th>
            </tr>
            
        </thead>
        <tbody>
            <volist  name="list" id="vo">
                <tr lay-fliter="test3">
                    <td>{$vo.id}</td>
                    <td>{$vo.title}</td>
                    <td>
                        <button type="button" data-id="{$vo.id}" class="layui-btn layui-btn-primary layui-btn-xs delete-btn" title="删除"><i class="layui-icon">&#xe640;</i></button>
                    </td>
                </tr>
            </volist>
        </tbody>
    </table>


    </form>
    <!-- 数据表格结束 -->
    </div>
    <!-- 内容结束 -->
    
  </div>
  <!-- layui-tab开始 -->
</body>

<include file="public/scripts"/>
<script>

/**
 * 添加
 */
 $('.add-btn').on('click',function (){
    layer.prompt({
        formType: 2,
        value: '',
        title: '请输入反馈类型标题',
        area: ['200px', '50px'] //自定义文本域宽高
        }, function(value, index, elem){
            $.ajax({
                url:"{:cmf_plugin_url('Feedback://admin_index/add')}",
                type:'post',
                data:{title:value},
                success:function(data){
                    let icon = ( data.code == 200 ) ? 1 : 5 ;
                    layer.msg( data.message , { time:1200 , icon:icon },function(){
                        window.location.reload();
                    });
                },
                error:function(data){
                    console.log(data);
                    layer.msg('系统错误',{time:1200,icon:5});
                }
            })   
        layer.close(index);
    });
})

/**
 * 删除
 */
 $('.delete-btn').on('click',function(){
        let id = $(this).data('id');
        //询问
        layer.confirm('确定要删除吗？',{icon:3,title:'提示',btn:['删除','取消']}
        ,function(index,layero){
            $.ajax({
                url:"{:cmf_plugin_url('Feedback://admin_index/deleteType')}",
                type:'post',
                data:{id:id},
                success:function(data){
                    let icon = ( data.code == 200 ) ? 1 : 5 ;
                    layer.msg( data.message , { time:1200 , icon:icon },function(){
                        window.location.reload();
                    });
                },
                error:function(data){
                    console.log(data);
                    layer.msg('系统错误',{time:1200,icon:5});
                }
            })   
        },function(index){});
       
    })

</script>
</html>